package com.leetcode.array;
// todo 未完成
public class Leetcode80 {

    public int removeDuplicates(int[] nums) {

        if (nums.length == 0) {
            return 0;
        }

        int k = 1; // 下一个要覆盖的位置
        int count = 1; // 统计重复的次数
        for (int i = 1 ; i < nums.length ; i ++) {
            if (nums[i] == nums[i - 1]) {
                count ++;
            } else {
                count = 1;
            }
            if (count <= 2) {
                nums[k++] = nums[i];
            }
        }
        return k;
    }



    public static void main(String[] args) {
        int [] arr = {0,0,1,1,1,1,2,3,3};
        int count = new Leetcode80().removeDuplicates(arr);
        for (int i = 0 ; i < count ; i ++) {
            System.out.println(arr[i]);
        }

    }
}